package demo;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import java.awt.*;
import java.awt.event.*;

public class JSplitPaneDemo extends JApplet implements SwingConstants {

	JPanel jpanel = new JPanel();
	JPanel jpane2 = new JPanel();
	JList jList = new JList(new String[] { "China", "England", "America" });

	JLabel jLabel = new JLabel("main");

	public void init() {
		Container contentPane = getContentPane();
		contentPane.setLayout(new BorderLayout());

		jList.addListSelectionListener(new ListSelectionListener() {

			public void valueChanged(ListSelectionEvent e) {
				// TODO Auto-generated method stub
				JList jlist = (JList) e.getSource();
				((JLabel) jpane2.getComponent(0)).setText(jlist
						.getSelectedValue().toString());

			}

		});
		jpanel.add(jList);
		jpanel.setAutoscrolls(true);

		JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
				jpanel, jpane2);
		jSplitPane.setOneTouchExpandable(true);
		jSplitPane.setDividerLocation(100);
		jpane2.add(new JLabel("", JLabel.LEFT));
		jpanel.setMinimumSize(new Dimension(70, 100));
		jpane2.setMinimumSize(new Dimension(500, 600));

		contentPane.add(jSplitPane);

		show();
	}
}
